package com.rock.platform.entity;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONObject;
import com.rock.platform.util.JsonUtils;

/**
 * 分页处理实体
 * 
 */
public class PageEntity
{

    private List<? extends Object> data = new ArrayList<Object>();
    private int total;
    /**
     * 辅助属性map
     */
    private Map<String,? extends Object> map;

    /**
     * 序列化分页实体为jsonString
     * 
     * @return
     * @throws Exception
     */
    public String toString()
    {
        JSONObject jsonObject = new JSONObject();

        jsonObject.put("success", true);
        jsonObject.put("total", total);
        jsonObject.put("data", JsonUtils.getJsonString(data));
        if (map != null)
        {
            jsonObject.putAll(map);
        }

        return jsonObject.toString();
    }

    public List<? extends Object> getData()
    {
        return data;
    }

    public void setData(List<? extends Object> data)
    {
        this.data = data;
    }

    public int getTotal()
    {
        return total;
    }

    public void setTotal(int total)
    {
        this.total = total;
    }

    public void setMap(Map<String,? extends Object> map)
    {
        this.map = map;
    }

    public Map<String, ? extends Object> getMap()
    {
        return map;
    }
}
